#pragma once

#include <base/macro/aeval.h>

/* LOG2/pow2常数 */
#define POW2_M(x)		__POW2_##x
#define __POW2_0		1
#define __POW2_1		2
#define __POW2_2		4
#define __POW2_3		8
#define __POW2_4		16
#define __POW2_5		32
#define __POW2_6		64
#define __POW2_7		128
#define __POW2_8		256
#define __POW2_9		512
#define __POW2_10		1024
#define __POW2_11		2048
#define __POW2_12		4096
#define __POW2_13		8192
#define __POW2_14		16384
#define __POW2_15		32768
#define __POW2_16		65536
#define __POW2_17		131072
#define __POW2_18		262144
#define __POW2_19		524288
#define __POW2_20		1048576
#define __POW2_21		2097152
#define __POW2_22		4194304
#define __POW2_23		8388608
#define __POW2_24		16777216
#define __POW2_25		33554432
#define __POW2_26		67108864
#define __POW2_27		134217728
#define __POW2_28		268435456
#define __POW2_29		536870912
#define __POW2_30		1073741824
#define __POW2_31		2147483648
#define __POW2_32		4294967296

#define LOG2_M(const_size)	__LOG2_##const_size /* EXPAND(DEFER(__MCAT)(__LOG2_, const_size)) */
#define __LOG2_1		0
#define __LOG2_2		1
#define __LOG2_4		2
#define __LOG2_8		3
#define __LOG2_16		4
#define __LOG2_32		5
#define __LOG2_64		6
#define __LOG2_128		7
#define __LOG2_256		8
#define __LOG2_512		9
#define __LOG2_1024		10
#define __LOG2_2048		11
#define __LOG2_4096		12
#define __LOG2_8192		13
#define __LOG2_16384		14
#define __LOG2_32768		15
#define __LOG2_65536		16
#define __LOG2_131072		17
#define __LOG2_262144		18
#define __LOG2_524288		19
#define __LOG2_1048576		20
#define __LOG2_2097152		21
#define __LOG2_4194304		22
#define __LOG2_8388608		23
#define __LOG2_16777216		24
#define __LOG2_33554432		25
#define __LOG2_67108864		26
#define __LOG2_134217728	27
#define __LOG2_268435456	28
#define __LOG2_536870912	29
#define __LOG2_1073741824	30
#define __LOG2_2147483648	31
#define __LOG2_4294967296	32
